package com.tql.mall.sms.controller;


import com.tql.mall.common.result.R;
import com.tql.mall.sms.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "短信服务接口")
@RestController
@RequestMapping("/sms/")
public class SmsController {

    @Autowired
    private SmsService smsService;

    /**
     * 发送手机验证码
     *
     * @return
     */
    @ApiOperation(value = "发送短信")
    @GetMapping("/customer/sendCode/{phone}")
    public R<Void> sendCode(@PathVariable String phone) throws Exception {
        boolean flag = smsService.sendCode(phone);
        if (flag) {
            return R.ok();
        } else {
            return R.fail();
        }
    }
}
